package participle;

import java.io.StringReader;

import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.apache.lucene.analysis.tokenattributes.CharTermAttributeImpl;
import org.apache.lucene.analysis.tokenattributes.TermAttribute;
import org.apache.lucene.util.Version;

public class English {

	public static void main(String[] args) throws Exception {
		
		String s = "May you have enough happiness to make you sweet,enough trials "
				+ "to make you strong,enough sorrow to keep you human,enough hope "
				+ "to make you happy? Always put yourself in others’shoes.If you "
				+ "feel that it hurts you,it probably hurts the other person, too.";
		StringReader reader = new StringReader(s);
		StandardAnalyzer analyzer = new StandardAnalyzer(Version.LUCENE_33);
		TokenStream tokenStream = analyzer.tokenStream(null, reader);
		boolean hasnext = tokenStream.incrementToken();
		while(hasnext){
			
			TermAttribute att = tokenStream.getAttribute(TermAttribute.class);
			System.out.println(att.term());
			hasnext = tokenStream.incrementToken();
		}
	}
}
